package com.neutech.bigdecimal;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.math.BigDecimal;
import java.util.zip.GZIPOutputStream;

public class BigDecimalTest {
    public static void main(String[] args) {
        System.out.println(0.2 + 0.1);
        System.out.println(0.3 - 0.1);
        System.out.println(0.2 * 0.1);
        System.out.println(0.3 / 0.1);


        BigDecimal bigDecimal = new BigDecimal(2);
        BigDecimal bDouble = new BigDecimal(2.3);
        BigDecimal bString = new BigDecimal(2.3);
        System.out.println("bigDecimal = " +  bigDecimal);
        System.out.println("bDouble = " + bDouble);
        System.out.println("bString = " + bString);


        BigDecimal bDouble1 = BigDecimal.valueOf(2.3);
        BigDecimal bDouble2 = new BigDecimal(Double.toString(2.3));
        System.out.println("bDouble1 = " + bDouble1);
        System.out.println("bDouble2 = " + bDouble2);


        BigDecimal bd1 = BigDecimal.valueOf(0.2);
        BigDecimal bd2 = BigDecimal.valueOf(0.1);
        System.out.println(bd1.add(bd2)); // 加法
        System.out.println(bd1.subtract(bd2)); // 减法
        System.out.println(bd1.multiply(bd2)); // 乘法
        System.out.println(bd1.divide(bd2)); // 除法
    }
}
